﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HotelAdd.aspx.cs" Inherits="FastTravel.IntranetWeb.HotelAdd" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>Добавление отеля</title>
</head>
<body>
	<form id="formHotelAdd" runat="server">
	<ext:ResourceManager ID="resourceManager" runat="server" Theme="Gray"/>

	<!-- resort storage -->
	<ext:Store runat="server" ID="ResortStore" AutoLoad="false" OnRefreshData="ResortRefresh">
		<DirectEventConfig>
			<EventMask ShowMask="false" />
		</DirectEventConfig>
		<Reader>
			<ext:JsonReader IDProperty="ID">
				<Fields>
					<ext:RecordField Name="ID" Type="String" Mapping="ID" />
					<ext:RecordField Name="Name" Type="String" Mapping="Name" />
				</Fields>
			</ext:JsonReader>
		</Reader>
		<Listeners>
			<Load Handler="#{comboResort}.setValue(#{comboResort}.store.getAt(0).get('ID'));" />
		</Listeners>
	</ext:Store>

	<!-- form -->
	<ext:Panel ID="pnlHotelAdd" runat="server" Border="false" AutoWidth="true" ButtonAlign="Center" Layout="Fit">
			<Items>
				<ext:TabPanel ID="tabPnlGeneral" runat="server" AutoWidth="true" ActiveTabIndex="0">
					<Items>
						<ext:Panel ID="pnlHotelInfo" runat="server" Title="Инормация об отеле" AutoHeight="true" AutoWidth="true" Padding="10" LabelWidth="75" Layout="Form">
							<Items>
						<ext:TextField runat="server" ID="txtName" Selectable="true" FieldLabel="Название" Width="400" AllowBlank="false"/>
						<ext:HtmlEditor ID="htmlDescription" runat="server" HideLabel="true" Height="180" Text="" FieldLabel="Описание"/>
						<ext:ComboBox runat="server" ID="comboCountry" SelectedIndex="0" FieldLabel="Страна" 
						EmptyText="Загрузка..."  ValueNotFoundText="Загрузка..." ForceSelection="true"  
						TriggerAction="All" SelectOnFocus="true" Width="250">
						
							<Listeners>
								<Select Handler="#{comboResort}.clearValue(); #{ResortStore}.reload();" />
							</Listeners> 	

						</ext:ComboBox>
						
						<ext:ComboBox runat="server" ID="comboResort" StoreID="ResortStore" TypeAhead="true" 
						Mode="Local"  ForceSelection="true" TriggerAction="All" DisplayField="Name" ValueField="ID"
						FieldLabel="Курорт" EmptyText="Загрузка..."  ValueNotFoundText="Загрузка..." Width="250" IsRemoteValidation="true">
						</ext:ComboBox>

						<ext:ComboBox ID="comboRaiting" runat="server" SelectedIndex="0" Width="250">
							<Items>
									<ext:ListItem Text="Без рейтинга" Value="0"/>
									<ext:ListItem Text="1 звезда" Value="1"/>
									<ext:ListItem Text="2 звезды" Value="2"/>
									<ext:ListItem Text="3 звезды" Value="3"/>
									<ext:ListItem Text="4 звезды" Value="4"/>
									<ext:ListItem Text="5 звезд" Value="5"/>
							</Items>
						</ext:ComboBox>

							</Items>
						</ext:Panel>
					</Items>
				</ext:TabPanel>
			</Items>
			<Buttons>
				<ext:Button ID="btnSave" runat="server" Text="Сохранить" CausesValidation="true" Icon="Accept">
					<DirectEvents>
						<Click OnEvent="BtnSaveClick"/>
					</DirectEvents>	
					<Listeners>	
						<Click Handler="
							txtName.validate(); 
							if (!txtName.isValid()) { 
								txtName.focus(); // if name invalid, focus the field.
								return false;
							}"
							/>
					</Listeners>
				</ext:Button>
			</Buttons>
	</ext:Panel>
	</form>
</body>
</html>
